#include <iostream>
#include <set>

using namespace std;

void test(){
    set<int> number;
    
    int n,m;
    cin >> n >> m;
    int temp = 0;
    for(int i = 0;i < n;++i)
    {
        cin >> temp;
        number.insert(temp);
    }
    for(int j =0;j< m;++j)
    {
        cin >> temp;
        number.insert(temp);
    }

    for(auto &ele:number)
    {
        cout << ele << " ";
    }
    cout <<endl;
}

int main()
{
    test();
    return 0;
}

